var demo = angular.module("demo", ["RongWebIMWidget"]);
demo.controller("main", ["$scope", "WebIMWidget", "$http", function($scope, WebIMWidget, $http) {
          
            
	    			$.ajax({       
       url:  "http://app.jiagangwangluo.com/api/api/user/selectOne?id="+45,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					   $scope.targetType =1;        //1：私聊 更多会话类型查看http://www.rongcloud.cn/docs/api/js/global.html#ConversationType
               $scope.targetId = data.data.userName;        //私聊的id
				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});
	  
          


    //注意实际应用中 appkey 、 token 使用自己从融云服务器注册的。
    
   var config = {    //这个是用户注册的生成的  token
        appkey: 'k51hidwqkno2b',
        token: "wuOWD2K/o9/0y01P9gi6vOqHBmNtAjrMIN4yI3XixMP8R48XW7yZ9sq/QQy6C1S5ufcrZDQnyLI=",// "b/jvjEFD41TIVT0nsf9+L3ryPPkHsvRwWZV8SVI5ICcZ2I5Nl4OdNO01OjZxjjmVlD2dmk4RZ90=",
        displayConversationList: true,
         style:{
            left:3,
            bottom:3,
            width:430
        },
        onSuccess: function(id) {
        	
            $scope.user = id;
            alert("==="+id);
            document.title = '用户：' + id;
            console.log('连接成功：' + id);
            
        },
        onError: function(error) {
            console.log('连接失败：' + error);
        }
    };
    RongDemo.common(WebIMWidget, config, $scope);
    
}]);

